#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
int M,N,T;
char a[205][205];
int visited[205][205][15];
struct Pos{
    int r,c,t,ck;
    Pos(){};
    Pos(int rr,int cc,int tt,int cck):r(rr),c(cc),t(tt),ck(cck){};
};
Pos start,goal;
queue<Pos> q;
struct Dir{
    int r,c;
}dir[4]={{1,0},{-1,0},{0,1},{0,-1}};
int main(){
    cin>>M>>N>>T;
    for(int i=1;i<=M;i++)
    for(int j=1;j<=N;j++){
        cin>>a[i][j];
        if(a[i][j]=='@'){
            start=Pos(i,j,0,T);
        }else if(a[i][j]=='+'){
            a[i][j]='*';
            goal=Pos(i,j,-1,-1);
        }
    }
    visited[start.r][start.c][T]=1;
    q.push(start);
    Pos p;
    while(!q.empty()){
        p=q.front();
        if(p.r==goal.r&&p.c==goal.c){
            break;
        }
        q.pop();
        int nr,nc;
        for(int i=0;i<4;i++){
            nr=p.r+dir[i].r;
            nc=p.c+dir[i].c;
            if(a[nr][nc]=='*'&&!visited[nr][nc][p.ck]){
                visited[nr][nc][p.ck]=1;
                q.push(Pos(nr,nc,p.t+1,p.ck));
            }
            if(a[nr][nc]=='#'&&p.ck>0&&!visited[nr][nc][p.ck-1]){
                visited[nr][nc][p.ck]=1;
                q.push(Pos(nr,nc,p.t+1,p.ck-1));
            }
        }
    }
    if(q.empty()){
        cout<<-1<<endl;
    }else{
        cout<<p.t<<endl;
    }
    return 0;
}